package views;

import java.awt.FlowLayout;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import org.ini4j.Ini;

public class FenetreProgressBar extends JDialog {
	private static final long serialVersionUID = -5602623468580779850L;
	protected JProgressBar progressBar = new JProgressBar(0,100);
	protected JLabel label;
	protected JPanel panel;
	protected JFrame frame;
	
	public FenetreProgressBar(JFrame frame, Ini langIni) {
		this.frame = frame;
		
		// panel
		panel = new JPanel(new FlowLayout());
		
		// progress bar
		progressBar.setString("Working");
		progressBar.setStringPainted(true);
		progressBar.setValue(0); 
		
		// label
		label = new JLabel("Progress: ");
		
		
		// add dans le panel
		panel.add(label);
		panel.add(progressBar);
		
		this.initJDialog();
	}
	
	public void initJDialog(){
		this.setSize(100,50);
		this.setLocationRelativeTo(this.frame); // center on screen
		this.toFront(); // raise above other java windows
		this.setContentPane(this.panel);
		this.setModal(true);
		this.setVisible(true);
	}
	
	public void setValue(int value){
		this.progressBar.setValue(value);
	}
}
